package com.xls.box2023.home;

import com.lzz.bottomencapsulation.entity.VersionEntity;
import com.lzz.bottomencapsulation.net.RequestCallBack;
import com.lzz.bottomencapsulation.net.RetrofitBase;
import com.lzz.bottomencapsulation.utils.AppUtils;
import com.xls.box2023.BoxAppLication;
import com.xls.box2023.entity.AccountBalanceEntity;
import com.xls.box2023.entity.UserEntity;
import com.xls.box2023.entity.YouXiEntity;
import com.xls.box2023.network.RequestManager;

import java.util.ArrayList;

public class HomeNetWorkUtil {
 /**
 * 单例模式
 **/
 private static HomeNetWorkUtil mHomeNetWorkUtil = null;
     /**
      * 构造函数私有化
      **/
     private HomeNetWorkUtil() {
     }
     /**
      * 公有的静态函数，对外暴露获取单例对象的接口
      **/
     public static HomeNetWorkUtil getInstance() {
         if (mHomeNetWorkUtil == null) {
             synchronized (HomeNetWorkUtil.class) {
                 if (mHomeNetWorkUtil == null) {
                     mHomeNetWorkUtil = new HomeNetWorkUtil();
                 }
             }
         }
         return mHomeNetWorkUtil;
     }

    public void getAccountBalance(RequestCallBack<AccountBalanceEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getAccountBalance(), callBack);
    }

    public void getMyApps(RequestCallBack<ArrayList<YouXiEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getMyApps(), callBack);

    }

    public void getUserInfo(RequestCallBack<UserEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getUserInfo(), callBack);
    }


    public void getAPKURL(String appid,RequestCallBack<String> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getAPKURL(appid), callBack);
    }

    public void checkUpdate(RequestCallBack<VersionEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                checkUpdate(AppUtils.getPackageName(BoxAppLication.getBaseApplication())), callBack);
    }

    public void getUserAgentInfo(RequestCallBack<UserEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getUserAgentInfo(), callBack);
    }
}
